<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib prefix="shiro"  uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style>
	.scheduleBox{width:400px; height:auto}
</style>
<script>
$(function(){
	$('.date-picker').datepicker({
		autoclose: true,
		todayHighlight: true
	}).next().on(ace.click_event, function(){
		$(this).prev().focus();
	});
	
	var datatable = $("#askTable").DataTable({
		"language":{
			"url": "${pageContext.request.contextPath}/resources/admin/assets/de_DE.txt"
		},
		"dom": '<"top" >rt<"bottom" ifp><"clear">',
		"lengthMenu": [20, 25, 30,35],
		"pagingType": "full_numbers",
		"order":[[6,'desc']],
		"filter": false,
		"processing": true,
		"serverSide": true,
		"ajax": {
            "url": "${pageContext.request.contextPath}/cms/ask/askList.do",
            "type": "post"
        },
		 "columns": [
			 	{ "data": "name",width:"80"},
			 	{ "data": "telphone",width:"80"},
			 	{ "data": "email",width:"80"},
				{ "data": "title",width:"180"},
				{ "data": "context",width:"200"},
				{ "data": "ip",width:"80"},
				{ "data": "createDate" ,"render":function(data,type,row){
					if(data == undefined){
						return '';
					}
					var d = new Date(data);
					var month = d.getMonth()+1;
					month = month < 10 ?"0"+month:month;
					return d.getFullYear()+"-"+month+"-"+d.getDate();

                },width:"65"},
				{ "data": null,orderable: false,"render":function(data,type,row){
					return   '<shiro:hasPermission name="cms:ask:del"><a href="#" class="green" onclick="delAsk('+row.id+')"><i class="ace-icon fa fa-pencil"></i>删除</a></shiro:hasPermission>';
				}} 
	        ]
	});
	
	$('#refreshUser').click(function(){
		datatable.draw();
	})
	
	$('#delCategory').click(function(){
		var selected = datatable.rows('.selected').data();
	//	alert(selected.username)
		alert( datatable.rows('.selected').data().length +' row(s) selected' );
	})
	
	$(document).on('click', 'th input:checkbox' , function(){
		var that = this;
		$(this).closest('table').find('tr > td:first-child input:checkbox')
		.each(function(){
			$(this).closest('tr').toggleClass('selected');
			this.checked = that.checked;
		});
	});
	
	$('#askTable tbody').on( 'click', 'tr', function () {
        $(this).toggleClass('selected');
    } );
	
	$('#askTable tbody').on( 'click', 'tr input:checkbox', function () {
		//$(this).closest('tr').toggleClass('selected');
		$(this).parent().toggleClass('selected');
    });
});


function delAsk(aid){
	var url = "${pageContext.request.contextPath}/cms/ask/askDel";
	$.post(url,{aid:aid},function(data){
		//var data = eval('(' + data + ')');
		if(data.success){
//			art.dialog({content:data.msg,fixed:true,drag:true,resize:true,time:2,left:'100%',top:'100%',width:165,height:65});
			art.dialog({content:data.msg,resize:true,time:2,icon:'succeed',ok:function(){this.close()}});
			$('#askTable').DataTable().draw() ;		//重新刷新数据表格
		}
	})
}

</script>
<div class="breadcrumbs">
	<script type="text/javascript">
		try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
	</script>
	<ul class="breadcrumb">
		<li>
			<i class="ace-icon fa fa-home home-icon"></i>
			<a href="#">首页</a>
		</li>
		<li class="active">客户留言内容管理</li>
	</ul><!-- /.breadcrumb -->
	
	<div class="nav-search" id="nav-search">
		<form class="form-search">
			<span class="input-icon">
				<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
				<i class="ace-icon fa fa-search nav-search-icon"></i>
			</span>
		</form>
	</div><!-- /.nav-search -->
</div>
<div class="page-content">
	<div class="row">
		<div class="col-sm-12">
			<div class="widget-box widget-color-dark">
				<div class="widget-header">
					<h5 class="widget-title">前台留言列表</h5>
				</div>
				<div class="widget-body">
					<div class="widget-main padding-6">
						<table class="table row-border cell-border  " id="askTable">
							<thead>
							<tr>
								<th>姓名</th>
								<th>电话</th>
								<th>邮箱</th>
								<th>标题</th>
								<th>内容</th>
								<th>访问ip</th>
								<th>发布时间</th>
								<th>操作</th>
							</tr>
							</thead>
						</table>
					</div>
				</div>
			</div>

		</div>
	</div>
</div>